namespace DotNetNuke.HttpModules
{
    using DotNetNuke.Entities.Users;
    using System;
    using System.Web;

    public class UsersOnlineModule : IHttpModule
    {
        public void Dispose()
        {
        }

        public void Init(HttpApplication application)
        {
            application.AuthorizeRequest += new EventHandler(this.OnAuthorizeRequest);
        }

        public void OnAuthorizeRequest(object s, EventArgs e)
        {
            HttpApplication app = (HttpApplication) s;
            if (!app.Request.Url.LocalPath.EndsWith("Install.aspx"))
            {
                UserOnlineController objUserOnlineController = new UserOnlineController();
                if (objUserOnlineController.IsEnabled())
                {
                    objUserOnlineController.TrackUsers();
                }
            }
        }

        public string ModuleName
        {
            get
            {
                return "UsersOnlineModule";
            }
        }
    }
}

